﻿@using IdentityServer4.Extensions
@using Microsoft.AspNetCore.Mvc.Localization
@using Reborn.IdentityServer4.Admin.UI.Configuration
@using Reborn.IdentityServer4.Admin.UI.Configuration.Constants
@inject IViewLocalizer Localizer
@inject AdminConfiguration AdminConfiguration

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <link rel="icon" type="image/x-icon" href="@UrlHelper.Content(AdminConfiguration.FaviconUri)"/>
    <link rel="shortcut icon" type="image/x-icon" href="@UrlHelper.Content(AdminConfiguration.FaviconUri)"/>
    <title>@ViewData["Title"] - @AdminConfiguration.PageTitle</title>

    <environment include="Development">
        <link href="~/dist/css/bundle.min.css" asp-append-version="true" rel="stylesheet"/>
        @await Html.PartialAsync("Common/ThemeResources")
        <link href="~/dist/css/web.css" asp-append-version="true" rel="stylesheet"/>
    </environment>
    <environment exclude="Development">
        <link href="~/dist/css/bundle.min.css" asp-append-version="true" rel="stylesheet"/>
        @await Html.PartialAsync("Common/ThemeResources")
        <link href="~/dist/css/web.min.css" asp-append-version="true" rel="stylesheet"/>
    </environment>

    @if (!string.IsNullOrEmpty(AdminConfiguration.CustomThemeCss))
    {
        <link href="@UrlHelper.Content(AdminConfiguration.CustomThemeCss)" asp-append-version="true" rel="stylesheet"/>
    }

    @await RenderSectionAsync("styles", false)
</head>
<body>

<div class="menu d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 border-bottom box-shadow">
    <!--Site name -->
    <h3 class="menu-logo my-0 mr-md-auto font-weight-normal">
        <a class="logo" asp-area="@CommonConsts.AdminUIArea" asp-controller="Home" asp-action="Index">@AdminConfiguration.PageTitle</a>
    </h3>

    <!--Menu item -->
    <vc:identity-server-link></vc:identity-server-link>

    <!--Menu item -->
    <div class="menu-item my-2 my-md-0 mr-md-3 dropdown">
        <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
            @Localizer["TitleConfiguration"]
        </button>
        <div class="dropdown-menu">
            <a class="dropdown-item" asp-area="@CommonConsts.AdminUIArea" asp-controller="Configuration" asp-action="Clients">@Localizer["LinkClients"]</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" asp-area="@CommonConsts.AdminUIArea" asp-controller="Configuration" asp-action="IdentityResources">@Localizer["LinkIdentityResources"]</a>
            <a class="dropdown-item" asp-area="@CommonConsts.AdminUIArea" asp-controller="Configuration" asp-action="ApiResources">@Localizer["LinkApiResources"]</a>
            <a class="dropdown-item" asp-area="@CommonConsts.AdminUIArea" asp-controller="Configuration" asp-action="ApiScopes">@Localizer["LinkApiScopes"]</a>
            <div class="dropdown-divider"></div>
            <a class="dropdown-item" asp-area="@CommonConsts.AdminUIArea" asp-controller="Grant" asp-action="PersistedGrants">@Localizer["LinkPersistedGrants"]</a>
        </div>
    </div>

    <!--Menu item -->
    <div class="menu-item my-2 my-md-0 mr-md-3 dropdown">
        <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
            @Localizer["TitleUsermanagement"]
        </button>
        <div class="dropdown-menu">
            <a class="dropdown-item" asp-area="@CommonConsts.AdminUIArea" asp-controller="Identity" asp-action="Users">@Localizer["LinkUsers"]</a>
            <a class="dropdown-item" asp-area="@CommonConsts.AdminUIArea" asp-controller="Identity" asp-action="Roles">@Localizer["LinkRoles"]</a>
        </div>
    </div>

    <!--Menu item -->
    <div class="menu-item my-2 my-md-0 mr-md-3 dropdown">
        <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
            @Localizer["TitleLogs"]
        </button>
        <div class="dropdown-menu">
            <a class="dropdown-item" asp-area="@CommonConsts.AdminUIArea" asp-controller="Log" asp-action="AuditLog">@Localizer["LinkAuditLogs"]</a>

            @if (!AdminConfiguration.HideUIForMSSqlErrorLogging)
            {
                <a class="dropdown-item" asp-area="@CommonConsts.AdminUIArea" asp-controller="Log" asp-action="ErrorsLog">@Localizer["LinkErrorLogs"]</a>
            }
        </div>
    </div>

    <!--Menu item -->
    @if (User.Identity.IsAuthenticated)
    {
        <a class="menu-item my-2 btn btn-outline-primary" asp-area="@CommonConsts.AdminUIArea" asp-action="Logout" asp-controller="Account">@User.GetDisplayName() - @Localizer["LinkLogout"]</a>
    }

    <!--Menu button - show in < MD -->
    <a class="my-2 btn btn-outline-primary menu-button" href="#">
        <span class="oi oi-menu" title="menu" aria-hidden="true"></span> @Localizer["MenuButton"]
    </a>
</div>

<div class="container">
    @RenderBody()

    <footer class="pt-4 my-md-5 pt-md-5 border-top">
        <div class="row">
            <div class="col-6 col-md">
                @AdminConfiguration.PageTitle
                <small class="d-block mb-3 text-muted">@Localizer["FooterCopyright"] @DateTime.Now.Year - @await Html.PartialAsync("Common/ApplicationVersion")</small>
            </div>
            <div class="col-md-3 text-right">
                @await Html.PartialAsync("Common/SelectTheme")
            </div>
            <div class="col-md-3 text-right">
                @await Html.PartialAsync("Common/SelectLanguage")
            </div>
        </div>


    </footer>
</div>

<environment include="Development">
    <script src="~/dist/js/bundle.min.js" asp-append-version="true"></script>
</environment>
<environment exclude="Development">
    <script src="~/dist/js/bundle.min.js" asp-append-version="true"></script>
</environment>

@await Html.PartialAsync("Common/Notification")

@await RenderSectionAsync("scripts", false)
</body>
</html>